// ÉÍÍÍÍÍÍ»ÉÍ» ÉÍ»ÉÍÍÍÍÍÍ»ÉÍÍÍÍ//¿ÚÄÄÄÄÄÄ¿ÚÄÄ¿ÚÄÄ¿ º ÉÍͼº ºÉ»º ºº ºº // ³³ ³³ ³³ ³ º ÈÍÍ»º ȼȼ ºÈÍ» Éͼº // ³³ ÚÄÄÄÙ³ ÀÙ ³ ÈÍ» ºº É» º º º ÈÍ// ÚÄÙ³ ÀÄÄÄ¿³ Ú¿ ³ Éͼ ºº ºº ºÉͼ ÈÍ» // ³ ³ ³³ ³³ ³ º ºº ºº ºº º//³ ³ ³ ³³ ³³ ³ ÈÍÍÍÍÍͼÈÍͼÈÍͼÈÍÍÍÍÍÍ// ÀÄÄÙ ÀÄÄÄÄÄÄÙÀÄÄÙÀÄÄÙ // Version 2.1a (c) 1991-1995 by Craig A. Cassidy A DOS command line utility that allows you to perform a word-processor-like search and replace on text strings in standard ASCII text files. ÚÂÂÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÀÁÁÁÁÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÁÁÁÁÙ SWITCH is a small utility designed to replace occurrences of strings in ASCII text files. The usefulness of this utility comes from its ability to perform numerous changes without user intervention thus allowing you to quickly make global changes to a file or to run the program from within a batch file. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÚÄÄÄÄÄÄÄÄÄÄÄ¿ ³ I. Syntax ÃÄ¿ ÀÄÂÄÄÄÄÄÄÄÄÄÙ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄ Command Line Syntax (Input File Format): ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ SWITCH targetfile /f:input-file ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄ Command Line Syntax (No Input File): ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ SWITCH targetfile search-string replace-string [optional parameters] ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - figure 1 - There are several possible command line options you may use with the SWITCH program. The format of the command line will vary greatly depending on the source of input for the "switch." In all cases the first required parameter will be the name of the file that you wish to change (referred to as "targetfile" in figure 1). If you wish to switch only one set of strings in your target file, you may specify them on the command line as the second and third required parameters. These two parameters are referred to as "search-string" and "replace-string" in the figure above. Optionally you could specify a source-file-name using the /f: option (ex: /f:myfile.txt). Doing this overrides the need to specify any options other than the targetfile. The "TargetFile" option may contain wildcards (i.e. "*" and "?"). These wildcards are used in the same manner they would be for a DOS command such as "DEL". When using wildcards SWITCH will process all files meeting the criteria specified. "targetfile" may also contain a fully specified path name (i.e. "C:\WORD\DOCS\MYFILE.TXT"). Both the "Search-String" and "Target-String" parameters may contain multiple word phrases (i.e. "Mary had a little lamb.") so long as they are surrounded by quotes. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ II. Optional Parameters ÃÄ¿ ÀÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ In order to customize the way SWITCH will do a search-and-replace, you must specify certain optional parameters either on the command line or in the input file. These parameters must be preceded by a "/" if used on the command line. Following is a description of each option: ÉÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Code ³ Description º ÇÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º c ³ Case-Sensitivity Off º º ³ º º ³ Turns case-sensitivity OFF when searching for a string. º º ³ When searching for "hello" in a text and SWITCH finds the º º ³ words "Hello" or "HELLO" they will be recognized and º º ³ switched if the "c" parameter is specified. SWITCH by º º ³ default will assume the search will be case sensitive. º ÇÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º v ³ View Altered Lines º º ³ º º ³ This option will display each altered line on the screen as º º ³ it is switched for the user to monitor. If the number of º º ³ changes exceeds the number of lines visible on the screen º º ³ then SWITCH will pause until the user has pressed a key. º ÇÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º p ³ Prompt For File Names º º ³ º º ³ When a number of files have been specified as targets for a º º ³ "switch" the user may wish to be prompted for confirmation º º ³ before each one is altered. The "p" option does just that. º º ³ As each file meeting the specified criteria is encountered, º º ³ SWITCH will request a (y/n) confirmation from the user. º ÇÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º w ³ Whole Words Only º º ³ º º ³ In some situations you may need to switch a word that could º º ³ be a subset of a larger word. To illustrate, suppose you º º ³ want to change all occurrences of the word "car" to º º ³ "automobile" in a text. Without the "w" option the word º º ³ "card" would be accidentally switched to "automobiled." º º ³ By default SWITCH will NOT assume that you are switching º º ³ whole words only. º ÇÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º s ³ Search Subdirectories * º º ³ º º ³ SWITCH is capable of searching and replacing strings in º º ³ multiple files at once using wildcards in the target-file º º ³ parameter. In addition to this feature, SWITCH provides a º º ³ means of searching for files outside of the specified (or º º ³ default) path. The "s" option will allow the program to º º ³ search for files in or BENEATH the specified path on the DOS º º ³ directory tree. º º ³ º º ³ C:\ÄÄÂÄÄDOS º º ³ ÃÄÄDATAÄÄÄÄÂTEXT º º ³ ÀÄÄUTILS ÀDOCS º º ³ º º ³ In the above directory tree if the following switch command º º ³ were to be executed: "SWITCH C:\DATA\*.TXT hi hello /s" º º ³ then all files ending in a ".TXT" in the "\DATA", º º ³ "\DATA\TEXT" and "\DATA\DOCS" directories would be switched. º ÇÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º f ³ Specify Input File * º º ³ º º ³ The "f" option allows for the switching of numerous search º º ³ and replace strings within the specified file(s) by using º º ³ an input file containing a list of all of the search and º º ³ replace strings SWITCH will use. The syntax for this º º ³ parameter is "/f:filename" where filename is the name of the º º ³ input file. º º ³ º º ³ Example: SWITCH *.txt /f:myfile º º ³ º º ³ In this example all ".TXT" files are switched using the º º ³ criteria found in the file called "MYFILE.TXT." See the º º ³ section titled "Input File Format" for details on creating º º ³ an input file. º ÇÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º r ³ Simply displays the registration information for the SWITCH º º ³ program. Please register this product. * º ÈÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ - Table One: Options - * Denotes options not available WITHIN an input file. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ III. Input File Format ÃÄ¿ ÀÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ When using an input file to perform multiple switches the following conventions must be followed for each line: search-string,replace-string,options One line for each search and replace string pair must be created. The strings must be separated by a comma and any options to be used in the switch must be placed on the same line separated again by a comma. An example of an input file might look like this: ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ hello,Hello,cw ³ ³ switch,SWITCH,c ³ ³ Old,New,cv ³ ³ Garbage Man,Waste Disposal Technician,cv ³ ³ Stewardess,Flight Attendant,cv ³ ³ ³ ³Ú¿Ú¿Ú¿ Ú¿ Ú¿³ ÀÙÀÙÀÙÀ¿ Ú¿ ÚÙ³Ú¿³ÀÙ À¿ Ú¿ Ú¿Ú¿³³Ú¿ÚÄ¿Ú¿ Ú¿ÚÄ¿Ú¿ÚÙ ÀÙÀÙ À¿Ú¿ÚÙÀ¿Ú¿Ú¿ÚÄÙÀÙÀÙÀÙÀÙ ÀÙÀ¿Ú¿ÚÙÀÙ ÀÙÀÙ ÀÙÀÙ ÀÙÀÙÀÙ ÀÙÀÙ - Example One - In Example One the five search-strings are replaced by their corresponding replace strings using the options particular to each pair. Note that phrases containing more than one word ARE valid. Unlike the command-line, multiple word phrases do not need to be surrounded by quotes. This file may be created with any editor capable of saving to an ASCII text file. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ IV. Examples ÃÄ¿ ÀÄÂÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The following examples demonstrate just a few ways you might use the SWITCH utility. The first example is a simple application where a field in the target file needs to be changed to a user's initials from a generic label called simply "initials": Ú´ No Input File Example ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ C:\>SWITCH datafile.txt Initials CAC /c /v /w ³ ³ ³ ³ ÀÂÄÙÀÄÂÄÄÙ ÀÄÄÄÄÂÄÄÄÄÄÙ ÀÄÄÂÄÄÄÙ ÀÂÙ ÀÄÄÂÄÄÄÙ ³ ³ ³ ³ ³ ³ ³ ÀÄ Optional Parameters ³ ³ ³ ³ ³ ³ ÀÄ Target string (what the search ³ ³ ³ ³ ³ ³ string will be switched to) ³ ³ ³ ³ ³ ÀÄ Search string ³ ³ ³ ³ ÀÄ Name of the target file to be switched ³ ³ ³ ÀÄ Executes the SWITCH Program ³ ³ ÀÄ DOS Command Prompt ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - Example Two - This example will switch all occurrences of the string "initials" to "CAC" in the file "DATAFILE.TXT." It will not care if "initials" is capitalized in any spot (via the "/c") and it will not switch any word that CONTAINS the word "initials" (via the "/w") such as "myinitials." SWITCH will also display each altered line on the screen for the user to view (via the "/v" option). The next example demonstrates an entirely different way of using SWITCH. In the following example the "/f:" option is used specifying that all search and replace pairs will be input from a text file rather than from the command-line. Ú´ Input File Example ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ C:\>SWITCH \data\*.txt /f:sw-file.txt /s /p ³ ³ ³ ³ ÀÂÄÙÀÄÂÄÄÙ ÀÄÄÄÄÂÄÄÄÄÙ ÀÄÄÄÄÄÂÄÄÄÄÄÄÙ ÀÄÂÄÙ ³ ³ ³ ³ ³ ³ ÀÄ Optional Parameters ³ ³ ³ ³ ³ ÀÄ Name of input file containing a list ³ ³ ³ ³ ³ of search and replace strings ³ ³ ³ ³ ÀÄ File specification (files to be switched) ³ ³ ³ ÀÄ Executes the SWITCH Program ³ ³ ÀÄ DOS Command Prompt ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - Example Three - The above example also makes use of the powerful "/s" option which, in this instance will allow SWITCH to perform on all ".TXT" files in the "\DATA" directory and ALL directories that fall beneath it on the directory tree. The "/p" option in this case will cause SWITCH to pause before each file matching the specified description to ask the user if the file should be altered similar as in the following example: SWITCH thisfile.txt? (y/n): _ The computer will halt processing until the user presses either the "y" or the "n" key therefore this option is not recommended for batch file applications. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ V. Disclaimer ÃÄ¿ ÀÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ SWITCH has been tested extensively and has not exhibited any problems causing loss of data integrity or otherwise. This does not mean that this product (or any other) is infallible. You should always keep backup copies of any data that is valuable to you. Use this software at your own risk. We can not be responsible for any damages due to loss of data, data corruption or other means. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ VI. Registration ÃÄ¿ ÀÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Should you find this software to be useful you are urged to register it. Once you have done this you will receive a registration number and proof of purchase as well as any future updates to the software as they become available. Register by sending $25 to: Craig Cassidy 58 S. Forge Manor Dr. Phoenixville, PA 19460 CompuServe: 72124,1723 Comments and suggestions are also welcome. ÛÛÛÛÛÛÛ¿ ÛÛ¿ ÛÛ¿ ÛÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛ¿ ÛÛ¿ ÛÛÚÄÄÄÄÙ ÛÛ³ ÛÛ³ ÀÄÛÛÚÄÄÙ ÀÄÛÛÚÄÙ ÛÛÚÄÄÄÙ ÛÛ³ ÛÛ³ ÛÛÛÛÛÛÛ¿ ÛÛ³Û¿ÛÛ³ ÛÛ³ ÛÛ³ ÛÛ³ ÛÛÛÛÛÛ³ ÀÄÄÄÄÛÛ³ ÛÛÛÛÛÛÛ³ ÛÛ³ ÛÛ³ ÛÛ³ ÛÛÚÄÛÛ³ ÛÛÛÛÛÛÛ³ ÛÛÛÚÛÛÛ³ ÛÛÛÛÛÛÛ¿ ÛÛ³ ÛÛÛÛÛÛ¿ ÛÛ³ ÛÛ³ ÀÄÄÄÄÄÄÙ ÀÄÄÙÀÄÄÙ ÀÄÄÄÄÄÄÙ ÀÄÙ ÀÄÄÄÄÄÙ ÀÄÙ ÀÄÙ V2.1a (c) 1991-1995 by Craig A. Cassidy